<!DOCTYPE html>
<!--
==========================================================================
云捷GO自动生成左树右表列表页面代码,只生成一次,按需修改.
生成日期：{{.table.CreateTime}}
生成路径: template/{{.table.ModuleName}}/{{.table.BusinessName}}/list.html
生成人：{{.table.FunctionAuthor}}
==========================================================================
-->
<html lang="zh">
<head>
    {{printf `{{template "header" (ossUrl)}}`}}
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>{{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}} {{if eq $column.HtmlType "input"}}
                            <li>
                                <p>{{$column.ColumnComment}}：</p>
                                <input type="text" name="{{$column.HtmlField}}"/>
                            </li>{{else if eq $column.HtmlType "select" "radio"}}{{if ne $column.DictType ""}}
                            <li>
                                <p>{{$column.ColumnComment}}：</p>
                                {{printf `{{getDictTypeSelect "%v" "%v" "%v" "" "" "所有" ""}}` $column.DictType $column.HtmlField $column.HtmlField}}
                            </li>{{else}}
                            <li>
                                <p>{{$column.ColumnComment}}：</p>
                                <select name="{{$column.HtmlField}}">
                                    <option value="">所有</option>
                                </select>
                            </li>{{end}} {{else if eq $column.HtmlType "datetime"}}
                            <li class="select-time">
                                <p>{{$column.ColumnComment}}：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                            </li>{{end}}{{end}}{{end}}
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            {{printf `{{getPermiButton .Session.uid "%v:%v:add" "$.operate.add()" "新增" "btn btn-success" "fa fa-plus"}}` .table.ModuleName .table.BusinessName}}
            {{printf `{{getPermiButton .Session.uid "%v:%v:edit" "$.operate.edit()" "修改" "btn btn-primary single disabled" "fa fa-edit"}}` .table.ModuleName .table.BusinessName}}
            <a class="btn btn-info" id="expandAllBtn">
                <i class="fa fa-exchange"></i> 展开/折叠
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-tree-table"></table>
        </div>
    </div>
</div>
{{printf `{{template "footer" (ossUrl)}}`}}
<script type="text/javascript">
    var addFlag = '{{printf `{{hasPermi .Session.uid "%v:%v:add"}}` .table.ModuleName .table.BusinessName}}';
    var editFlag =' {{printf `{{hasPermi .Session.uid "%v:%v:edit"}}` .table.ModuleName .table.BusinessName}}';
    var removeFlag = '{{printf `{{hasPermi .Session.uid "%v:%v:remove"}}` .table.ModuleName .table.BusinessName}}';
    {{range $index, $column := .table.Columns}} {{if ne $column.DictType ""}}var {{$column.HtmlField}}Datas = {{printf `{{getDictTypeData "%v"}}` $column.DictType}}; {{end}} {{end}}
    var prefix = ctx + "{{.table.ModuleName}}/{{.table.BusinessName}}";

    $(function () {
        var options = {
            code: "{{.table.TreeCode}}",
            parentCode: "{{.table.TreeParentCode}}",
            expandAll: false,
            expandFirst: false,
            uniqueId: "{{.table.PkColumn.ColumnName}}",
            url: prefix + "/list",
            createUrl: prefix + "/add?id={id}",
            updateUrl: prefix + "/edit?id={id}",
            removeUrl: prefix + "/remove?id={id}",
            exportUrl: prefix + "/export",
            modalName: "{{.table.FunctionName}}",
            columns: [{
                field: 'selectItem',
                radio: true
            },{{range $index, $column := .table.Columns}} {{if eq $column.IsPk "1"}}
                {
                    field: '{{$column.ColumnName}}',
                    title: '{{$column.ColumnComment}}',
                    visible: false
                },{{else if eq $column.IsList "1"}} {{if ne $column.DictType ""}}
                {
                    field: '{{$column.ColumnName}}',
                    title: '{{$column.ColumnComment}}',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel({{$column.HtmlField}}Datas, value);
                    }
                }, {{else}}
                {
                    field: '{{$column.ColumnName}}',
                    title: '{{$column.ColumnComment}}'
                }, {{end}} {{end}} {{end}}
                {
                    title: '操作',
                    align: 'center',
                    align: 'left',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.{{.table.PkColumn.ColumnName}} + '\')"><i class="fa fa-fa-plus"></i>新增</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.{{.table.PkColumn.ColumnName}} + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.{{.table.PkColumn.ColumnName}} + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.treeTable.init(options);
    });
</script>
</body>
</html>